#ifndef _OCCIDATATABLE_H_
#define _OCCIDATATABLE_H_


#include <buildspec.h>
#include <Client/ClientUtils/Network/TableAttributeDesc.h>
#include <Client/ClientUtils/Network/AbstractDataTable.h>
#include <Client/ClientUtils/Network/occi/occi_prototypes.h>

#include <string>
#include <boost/any.hpp>
#include <boost/ptr_container/ptr_vector.hpp>

namespace GST {
namespace ClientUtils {

	//prototypes:
	struct OCCIStatementHandle;
	typedef boost::shared_ptr<OCCIStatementHandle> OCCIStmtPtr;	

	//helpers:
	struct GST_API_EXPORT FieldInfo
	{
		TableAttributeDesc::DType dtype;
		std::string name;
		int dimension;
		bool notNull;
		int internalType;

		FieldInfo(const oc::MetaData & desc, int idx);
		FieldInfo(short _dtype, std::string _name, int _dim, bool _notNull);
		FieldInfo(const FieldInfo& other);
		FieldInfo& operator=(const FieldInfo& other);
	};

//------------------------- class of header file -----------------------

	/**
	 * Return table of OCCIDriver. 
	 */
	class GST_API_EXPORT OCCIDataTable
		: public AbstractDataTable
	{
		//local typedef:

	public:

		//OCCIDataTable(OCCIDataTable & other);
		virtual ~OCCIDataTable();
		
		///@name getter
		//@{
		virtual boost::any get(const std::type_info& returntype, int col);
		virtual bool isNull(int col);
		virtual std::string getName(int col) const;
		virtual TableAttributeDesc::DType getType(int col) const;
		virtual int getDimension(int col) const;
		virtual bool isNullable(int col) const;
		virtual unsigned int cols() const;
		virtual bool nextRow();
		//@}
		
	protected:
		virtual AbstractRDBAttributeDesc * newAttributeDesc(const TableAttributeDesc & desc, bool is_primaryKey=false) const;

	private:
		friend class OCCIDriver;

		//private c'tor
		OCCIDataTable(oc::ResultSet * r, OCCIStmtPtr s);

		///@name private members
		//@{
		oc::ResultSet * resultset;
		OCCIStmtPtr statement;
		unsigned int column_count;
		boost::ptr_vector<FieldInfo> columnInfos;
		//@}

	};//---------------- end of class ---------------------------------

	//typedefs:
	typedef boost::shared_ptr<OCCIDataTable> OCCIDataTablePtr;

} //of ns ClientUtils
} //of ns GST

#endif //_PGDATATABLE_H_